/*============================================================================*/
/*  Copyright (C) 2009-2014, iSOFT INFRASTRUCTURE SOFTWARE CO.,LTD.
 *  
 *  All rights reserved. This software is iSOFT property. Duplication 
 *  or disclosure without iSOFT written authorization is prohibited.
 *  
 *  @file       <Xcp_Cfg.c>
 *  @brief      <>
 *  
 *  <MCU:TC1782>
 *  
 *  @author     <>
 *  @date       <2014-12-22 11:33:38>
 */
/*============================================================================*/


/*=======[R E V I S I O N   H I S T O R Y]====================================*/
/*  <VERSION>    <DATE>    <AUTHOR>         <REVISION LOG>
 *  V1.0.0       20130306  Dongyuan.Sun     Initial version
 * 
 */
/*============================================================================*/

/*=======[V E R S I O N  I N F O R M A T I O N]===============================*/
#define XCP_CFG_C_VENDOR_ID  0
#define XCP_CFG_C_MODULE_ID  0
#define XCP_CFG_C_AR_MAJOR_VERSION  4
#define XCP_CFG_C_AR_MINOR_VERSION  0
#define XCP_CFG_C_AR_PATCH_VERSION  3
#define XCP_CFG_C_SW_MAJOR_VERSION  1
#define XCP_CFG_C_SW_MINOR_VERSION  0
#define XCP_CFG_C_SW_PATCH_VERSION  0
#define XCP_CFG_C_VENDOR_API_INFIX  0

/*=======[I N C L U D E S]====================================================*/
#include "Xcp_Cfg.h"


/*=======[V E R S I O N  C H E C K]===========================================*/

#if (XCP_CFG_C_AR_MAJOR_VERSION != XCP_CFG_H_AR_MAJOR_VERSION)
  #error "Xcp_Cfg.c : Mismatch in Specification Major Version"
#endif
#if (XCP_CFG_C_AR_MINOR_VERSION != XCP_CFG_H_AR_MINOR_VERSION)
  #error "Xcp_Cfg.c : Mismatch in Specification Major Version"
#endif
#if (XCP_CFG_C_AR_PATCH_VERSION != XCP_CFG_H_AR_PATCH_VERSION)
  #error "Xcp_Cfg.c : Mismatch in Specification Major Version"
#endif
#if (XCP_CFG_C_SW_MAJOR_VERSION != XCP_CFG_H_SW_MAJOR_VERSION)
  #error "Xcp_Cfg.c : Mismatch in Specification Major Version"
#endif
#if (XCP_CFG_C_SW_MINOR_VERSION != XCP_CFG_H_SW_MINOR_VERSION)
  #error "Xcp_Cfg.c : Mismatch in Specification Major Version"
#endif
#if (XCP_CFG_C_SW_PATCH_VERSION != XCP_CFG_H_SW_PATCH_VERSION)
  #error "Xcp_Cfg.c : Mismatch in Specification Major Version"
#endif

/*=======[M A C R O S]========================================================*/

/*=======[T Y P E   D E F I N I T I O N S]====================================*/

/*=======[E X T E R N A L   D A T A]==========================================*/

/*=======[E X T E R N A L   F U N C T I O N   D E C L A R A T I O N S]========*/

/*=======[I N T E R N A L   D A T A]==========================================*/

/*
 *  Tx & Rx Pdu Config
 */
STATIC CONST(Xcp_TxPduType, XCP_CONST_PBCFG) Xcp_TxPdu[1] = 
{
	{
  		0,
  		0x7b0 
	}
};

STATIC CONST(Xcp_RxPduType, XCP_CONST_PBCFG) Xcp_RxPdu[1] = 
{
	{
  		0,
  		0x7a0 
	}
};

/* STD */
#if XCP_GET_ID == STD_ON
STATIC CONST(uint8, XCP_CONST_PBCFG) IdInfo1[] = {"test"};


STATIC CONST(Xcp_IdInfoType, XCP_CONST_PBCFG) Xcp_IdInfo[XCP_NUM_OF_ID] = 
{
	{
		1, 0, sizeof(IdInfo1), &IdInfo1[0]
	}
};
#endif

/* fixed */
STATIC CONST(Xcp_GernalType, XCP_CONST_PBCFG) Xcp_Gernal = 
{
    XCP_MAX_CTO,
    #if (XCP_PL_PGM == (XCP_RESOURCE&XCP_PL_PGM))
    XCP_MAX_CTO_PGM,
    #endif
    XCP_MAX_DTO,
    #if (XCP_INTERLEAVED_MODE == STD_ON)
    XCP_QUEUE_SIZE,
    #endif
    #if (XCP_MASTER_BLOCK_MODE == STD_ON)
    XCP_MAX_BS,
    XCP_MIN_ST,
        #if (XCP_PL_PGM == (XCP_RESOURCE&XCP_PL_PGM))
        XCP_MAX_BS_PGM,
        XCP_MIN_ST_PGM,
        #endif
    #endif
    #if (XCP_BUILD_CHECKSUM == STD_ON)
    XCP_MAX_CHECKSUM_SIZE,
    #endif
    #if (XCP_GET_ID == STD_ON)
    XCP_NUM_OF_ID,
    &Xcp_IdInfo[0],
    #endif

    #if (XCP_PL_DAQ == (XCP_PL_DAQ & XCP_RESOURCE))
    XCP_MAX_EVENT_CHANNEL,
    XCP_MIN_DAQ,
    XCP_MAX_DAQ,
    #if (XCP_DAQ_CONFIG_TYPE == XCP_DAQ_DYNAMIC)
    XCP_DAQ_COUNT,
    #endif
    XCP_ODT_ENTRY_SIZE_DAQ,
    XCP_ODT_ENTRY_SIZE_STIM,
    
    #if (XCP_TIMESTAMP_TYPE != XCP_TS_NO_TS)
	XCP_TS_CNT_ID,
    #endif        
    #endif
    XCP_TANSFER_TIME_OUT,
};

/*
 * DAQ Config
 */
#if (XCP_PL_DAQ == (XCP_PL_DAQ&XCP_RESOURCE))


#if (XCP_MIN_DAQ != 0)
STATIC VAR(Xcp_EntryType, XCP_CONST_PBCFG) Xcp_PredefEntry[0] = 
{
};

STATIC VAR(Xcp_OdtType, XCP_CONST_PBCFG) Xcp_PredefOdt[0] = 
{
};
#endif /* (XCP_MIN_DAQ != 0) */

#if (XCP_DAQ_CONFIG_TYPE == XCP_DAQ_STATIC)
STATIC VAR(Xcp_EntryType, XCP_VAR) Xcp_StaticEntry[3];  /* Sum(XcpMaxOdtEntries(Daq) * XcpMaxOdt(Daq)) */

STATIC VAR(Xcp_OdtType, XCP_CONST_PBCFG) Xcp_StaticOdt[3] =   /* Sum(XcpMaxOdtEntries(Daq)) */
{
	{1,&Xcp_StaticEntry[0]},
	{1,&Xcp_StaticEntry[1]},
	{1,&Xcp_StaticEntry[2]},
};
#endif /* (XCP_DAQ_CONFIG_TYPE == XCP_DAQ_STATIC) */

STATIC CONST(Xcp_DaqListConfigType, XCP_CONST_PBCFG) Xcp_DaqConfig[XCP_MAX_DAQ] = 
{
	{
		#if (XCP_DAQ_CONFIG_TYPE == XCP_DAQ_STATIC)
        1,                          /* XcpMaxOdt */
        1,                          /* XcpMaxOdtEntries */
        #else
        0,                          /* XcpDaqSize */
        #endif
        #if (XCP_IDENTIFICATION_FIELD_TYPE == XCP_PID_ABSOLUTE)
        0,                          /* XcpFirstPid */
        #endif
        #if (XCP_DAQ_CONFIG_TYPE == XCP_DAQ_STATIC)
        DAQ,
        #else
        DAQ_STIM,
        #endif
        0,
        &Xcp_TxPdu[0],              /* XcpDaqTxPduRef */ 
        NULL_PTR,					/* XcpDaqRxPduRef */  
        #if (XCP_DAQ_CONFIG_TYPE == XCP_DAQ_STATIC)
        &Xcp_StaticOdt[0]
        #else
        NULL_PTR
        #endif       
		
	}, 
	{
		#if (XCP_DAQ_CONFIG_TYPE == XCP_DAQ_STATIC)
        1,                          /* XcpMaxOdt */
        1,                          /* XcpMaxOdtEntries */
        #else
        0,                          /* XcpDaqSize */
        #endif
        #if (XCP_IDENTIFICATION_FIELD_TYPE == XCP_PID_ABSOLUTE)
        1,                          /* XcpFirstPid */
        #endif
        #if (XCP_DAQ_CONFIG_TYPE == XCP_DAQ_STATIC)
        DAQ,
        #else
        DAQ_STIM,
        #endif
        1,
        &Xcp_TxPdu[0],              /* XcpDaqTxPduRef */ 
        NULL_PTR,					/* XcpDaqRxPduRef */  
        #if (XCP_DAQ_CONFIG_TYPE == XCP_DAQ_STATIC)
        &Xcp_StaticOdt[1]
        #else
        NULL_PTR
        #endif       
		
	}, 
	{
		#if (XCP_DAQ_CONFIG_TYPE == XCP_DAQ_STATIC)
        1,                          /* XcpMaxOdt */
        1,                          /* XcpMaxOdtEntries */
        #else
        0,                          /* XcpDaqSize */
        #endif
        #if (XCP_IDENTIFICATION_FIELD_TYPE == XCP_PID_ABSOLUTE)
        2,                          /* XcpFirstPid */
        #endif
        #if (XCP_DAQ_CONFIG_TYPE == XCP_DAQ_STATIC)
        DAQ,
        #else
        DAQ_STIM,
        #endif
        2,
        &Xcp_TxPdu[0],              /* XcpDaqTxPduRef */ 
        NULL_PTR,					/* XcpDaqRxPduRef */  
        #if (XCP_DAQ_CONFIG_TYPE == XCP_DAQ_STATIC)
        &Xcp_StaticOdt[2]
        #else
        NULL_PTR
        #endif       
			
	}
};

/*
 *  Event Channel Config
 */
 
/*  */

STATIC VAR(Xcp_AGType, XCP_VAR) Xcp_EvCh0Buffer[XCP_EVCHBUFFER_0_DEPTH]; 
STATIC VAR(Xcp_AGType, XCP_VAR) Xcp_EvCh1Buffer[XCP_EVCHBUFFER_1_DEPTH]; 
STATIC VAR(Xcp_AGType, XCP_VAR) Xcp_EvCh2Buffer[XCP_EVCHBUFFER_2_DEPTH]; 

STATIC CONST(Xcp_DaqNumType, XCP_CONST_PBCFG) Xcp_EvCh0DaqList[XCP_EVCH_0_DAQNUM] = {0,1,2}; 
STATIC CONST(Xcp_DaqNumType, XCP_CONST_PBCFG) Xcp_EvCh1DaqList[XCP_EVCH_1_DAQNUM] = {0,1,2}; 
STATIC CONST(Xcp_DaqNumType, XCP_CONST_PBCFG) Xcp_EvCh2DaqList[XCP_EVCH_2_DAQNUM] = {0,1,2}; 

STATIC CONST(uint8, XCP_CONST_PBCFG) XCP_EVENTCHANNEL_0[]   = {"EventChannel_0"}; 
STATIC CONST(uint8, XCP_CONST_PBCFG) XCP_EVENTCHANNEL_1[]   = {"EventChannel_1"}; 
STATIC CONST(uint8, XCP_CONST_PBCFG) XCP_EVENTCHANNEL_2[]   = {"EventChannel_2"}; 

STATIC CONST(Xcp_EventChannelConfigType, XCP_CONST_PBCFG) Xcp_EventChannelConfig[XCP_MAX_EVENT_CHANNEL] = 
{
	{
  		XCP_EVENTCHANNEL_0,
  		sizeof(XCP_EVENTCHANNEL_0),
  		3,
  		25,
  		1,
  		TIMESTAMP_UNIT_10MS,
  		XCP_EVENT_CONSIST_ODT,
  		DAQ,
  		EventChannel_0,
        XCP_EVCH_0_DAQNUM,
        XCP_EVCHBUFFER_0_DEPTH,
        &Xcp_EvCh0Buffer[0],
        &Xcp_EvCh0DaqList[0]
	},
	{
  		XCP_EVENTCHANNEL_1,
  		sizeof(XCP_EVENTCHANNEL_1),
  		3,
  		50,
  		1,
  		TIMESTAMP_UNIT_100MS,
  		XCP_EVENT_CONSIST_ODT,
  		DAQ,
  		EventChannel_1,
        XCP_EVCH_1_DAQNUM,
        XCP_EVCHBUFFER_1_DEPTH,
        &Xcp_EvCh1Buffer[0],
        &Xcp_EvCh1DaqList[0]
	},
	{
  		XCP_EVENTCHANNEL_2,
  		sizeof(XCP_EVENTCHANNEL_2),
  		3,
  		100,
  		1,
  		TIMESTAMP_UNIT_1S,
  		XCP_EVENT_CONSIST_ODT,
  		DAQ,
  		EventChannel_2,
        XCP_EVCH_2_DAQNUM,
        XCP_EVCHBUFFER_2_DEPTH,
        &Xcp_EvCh2Buffer[0],
        &Xcp_EvCh2DaqList[0]	
	}
};
#endif

#if (XCP_PL_CAL == (XCP_PL_CAL&XCP_RESOURCE))

#if (XCP_PAG_SUPPORT == STD_ON)
#if (XCP_MMU_SUPPORT == STD_OFF)
STATIC VAR(uint8, XCP_VAR) Xcp_PageBuffer0[Xcp_PageBuffer0_Size]; 

#else
STATIC CONST(Xcp_TLBInfoType, XCP_CONST_PBCFG) Xcp_TlbInfo[XCP_TLB_ENTRY_NUM] = /* 2 * XCP_MAX_SEGMENT */
{
    {0x50000,0xd4000,0x01,0x03,XCP_RAM_PAGE_PID,0x08},
	{0x50000,0xafe00,0x01,0x03,XCP_FLASH_PAGE_PID,0x00},  
};
#endif
#endif

STATIC CONST(Xcp_PageInfoType, XCP_CONST_PBCFG) Xcp_PageInfo[XCP_MAX_SEGMENT] = 
{
    {	
    	Xcp_PageBuffer0_Size,
        0xd4000000,
        0xd4000fff,    
        0xafe00000,
        0xafe00fff,
        #if (XCP_PAG_SUPPORT == STD_ON)
        #if (XCP_MMU_SUPPORT == STD_ON)
        0x50000000,
        0x50000fff,
        #else
        (uint32)Xcp_PageBuffer0
        #endif
        #endif		
	}    
};
#endif

CONST(Xcp_SegmentInfoType,XCP_CONST_PBCFG) Xcp_SegmentInfo = 
{
	#if (XCP_PL_CAL == (XCP_PL_CAL&XCP_RESOURCE))
	XCP_MAX_SEGMENT,
	#endif
    0x80000000,
    0x8fffffff,
    0xd0000000,
    0xd4ffffff,
    #if (XCP_PL_CAL == (XCP_PL_CAL&XCP_RESOURCE))
    Xcp_PageInfo,
    #if (XCP_PAG_SUPPORT == STD_ON)
    #if (XCP_MMU_SUPPORT == STD_ON)
    XCP_TLB_ENTRY_NUM,
    Xcp_TlbInfo
    #endif
    #endif
    #endif  
};

#if (XCP_PL_PGM == (XCP_PL_PGM&XCP_RESOURCE))
STATIC CONST(uint8, XCP_CONST_PBCFG) sectorName_No_0[] = {"Sector_1"}; 

CONST(Xcp_SectorInfoType, XCP_CONST_PBCFG) Xcp_SectorInfo[XCP_MAX_SECTOR] = 
{
    { 
        sectorName_No_0,            /* Name*/
        sizeof(sectorName_No_0),    /* name length */    
        0x0u,                      /* SECTOR_NUMBER */
        0x8fe00000ul,                   /* address */
        0x10000ul,                   /* length */
        XCP_FLASH_RANGE_CAL,        /* Flash range type*/
        0x8fe00000ul,                   /* progStartAddress */
        0x1000ul,                   /* progDataSize */
        0x00u,                      /* Erase number */
        0x01u,                      /* Program number */
        0x00u                       /* Programming method */ 	
	}    
};
#endif

/*
 * the code below is fixed
 */
CONST(Xcp_ConfigType, XCP_CONST_PBCFG) XcpConfig =
{
    &Xcp_TxPdu[0],
    &Xcp_RxPdu[0],
    &Xcp_Gernal,
    #if (XCP_PL_DAQ == (XCP_PL_DAQ & XCP_RESOURCE))
    &Xcp_DaqConfig[0],
    &Xcp_EventChannelConfig[0],
    #endif
};

/*=======[E N D   O F   F I L E]==============================================*/




